// -----------------------------------------------------------------------
// Copyright (c) Microsoft Corporation.  All rights reserved.
// -----------------------------------------------------------------------
using System;
using System.ComponentModel.Composition.Primitives;

namespace System.ComponentModel.Composition
{
    /// <summary>
    ///     Specifies discovery and creation options for an attributed part.
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
    public sealed class CompositionOptionsAttribute : Attribute
    {
        internal static readonly CompositionOptionsAttribute Default = new CompositionOptionsAttribute();
        internal static readonly CompositionOptionsAttribute Shared = new CompositionOptionsAttribute() { CreationPolicy = CreationPolicy.Shared };

        /// <summary>
        ///     Initializes a new instance of the <see cref="CompositionOptionsAttribute"/> class.
        /// </summary>
        public CompositionOptionsAttribute()
        {
        }

        /// <summary>
        ///     Gets or sets a value indicating the creation policy of the attributed part.
        /// </summary>
        /// <value>
        ///     One of the <see cref="CreationPolicy"/> values indicating the creation policy of the 
        ///     attributed part. The default is 
        ///     <see cref="System.ComponentModel.Composition.CreationPolicy.Shared"/>.
        /// </value>
        public CreationPolicy CreationPolicy { get; set; }

        /// <summary>
        ///     Gets or sets a value indicating when an attributed part will be discovered.
        /// </summary>
        /// <value>
        ///     One of the <see cref="CatalogDiscoveryMode"/> values indicating when the attributed part 
        ///     will be discovered by a <see cref="ComposablePartCatalog"/>. The default is 
        ///     <see cref="System.ComponentModel.Composition.CatalogDiscoveryMode.Auto"/>.
        /// </value>
        public CatalogDiscoveryMode CatalogDiscoveryMode { get; set; }        
    }
}
